<?php 
include("head.php"); ?>


<script language="JavaScript">

function checkBlank()

{

if(document.form1.site_name.value=='')

{

alert("Please give site name!");
document.form1.site_name.focus();
return false;

}

if(document.form1.site_url.value=='')

{

alert("Please give site url!");
document.form1.site_url.focus();
return false;

}
var str=document.form1.admin_email.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	testresults=true
	else
	{
	alert("Please Input A Valid Admin Email Address!")
	document.form1.admin_email.focus();
	return false;
	}

var str=document.form1.paypal_Email.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	testresults=true
	else
	{
	alert("Please Input A Valid Payple Email Address!")
	document.form1.paypal_Email.focus();
	return false;
	}
if(document.form1.results.value=='')

{

alert("Please give result per page for user section!");
document.form1.results.focus();
return false;

}


if(document.form1.addresult.value=='')

{
	alert("Please give result per page for admin section!");
	document.form1.addresult.focus();
	return false;
}
if(document.form1.impression.value=='')
{
	alert("Please give impression!");
	document.form1.impression.focus();
	return false;
}
if(document.form1.min_withdraw.value=='')
{
	alert("Please give min withdraw ammount");
	document.form1.min_withdraw.focus();
	return false;
}
if(document.form1.max_withdraw.value=='')
{
	alert("Please give max withdraw ammount");
	document.form1.max_withdraw.focus();
	return false;
}

return true;

}



</script>
<?php

$settingsql="SELECT * FROM ".GLOBALSETTINGS ;
$db = mysql_query($settingsql)or die(mysql_error());

$fet = mysql_fetch_array($db);

if(isset($_POST['submitvalue']))

{

	mysql_query("UPDATE ".GLOBALSETTINGS." SET 
	websiteName='".$_POST['site_name']."', 
	siteUrl='".$_POST['site_url']."', 
	adminEmail='".$_POST['admin_email']."',
	paypalEmail='".$_POST['paypal_Email']."',
	resultsPerPage='".$_POST['results']."',
	resultsPerPageAdmin='".$_POST['addresult']."',
	avgImpression='".$_POST['impression']."',
	min_withdraw='".$_POST['min_withdraw']."',
	max_withdraw='".$_POST['max_withdraw']."'
")

	or die(mysql_error('error'));

    echo'<script>window.location="settings.php?opt=1";</script>';

}

?>

<fieldset style="width:65%;">



	  <legend class="LEGEND">Settings Managment</legend>



<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td><form action="" method="post" name="form1" id="form1" onsubmit="return checkBlank();">

      <table width="100%" border="0" cellspacing="0" cellpadding="0">

        <tr>

          <td width="42%" height="30" valign="middle" style="color:#000000;font-size:12px; "><strong>Website Settings : </strong></td>

          <td width="58%" height="26" align="center"><font color="#FF0000"><blink>

            <?php if (isset($_GET['opt'])) if($_GET['opt']==1) echo'Website Settings update successfully.'; ?>

          <blink></font></td>

        </tr>

        <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Website Name</td>

          <td height="26"><input name="site_name" type="text" id="site_name" value="<?php echo $fet['websiteName']; ?>" size="40" /></td>

        </tr>

        <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Website URL</td>

          <td height="26"><input name="site_url" type="text" id="site_url" value="<?php echo $fet['siteUrl']; ?>" size="40" /></td>

        </tr>

        <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Admin Email</td>

          <td height="26"><input name="admin_email" type="text" id="admin_email" value="<?php echo $fet['adminEmail']; ?>" size="40" /></td>

        </tr>

		

        <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Paypal Email</td>

          <td height="26"><input name="paypal_Email" type="text" id="paypal_Email" value="<?php echo $fet['paypalEmail']; ?>" size="40" /></td>

        </tr>

		

        <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Results per page for User area </td>

          <td height="26"><label>

            <input name="results" type="text" id="results" value="<?php echo $fet['resultsPerPage']; ?>" size="5" />

          </label></td>

        </tr>

   

         <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Results for Admin area</td>

          <td height="26"><label>

            <input name="addresult" type="text" id="addresult" value="<?php echo $fet['resultsPerPageAdmin']; ?>" size="5" />

          </label></td>

        </tr>
         <tr>

          <td height="26" style="color:#000000;font-size:12px; ">Average Impression</td>

          <td height="26"><label>

            <input name="impression" type="text" id="impression" value="<?php echo $fet['avgImpression']; ?>" size="5" />

          </label></td>

        </tr>

		<tr>

          <td height="26" style="color:#000000;font-size:12px; ">Min withdraw ammount</td>

          <td height="26"><label>

            <input name="min_withdraw" type="text" id="min_withdraw" value="<?php echo $fet['min_withdraw']; ?>" size="5" />

          </label></td>

        </tr>

		<tr>

          <td height="26" style="color:#000000;font-size:12px; ">Max withdraw ammount</td>

          <td height="26"><label>

            <input name="max_withdraw" type="text" id="max_withdraw" value="<?php echo $fet['max_withdraw']; ?>" size="5" />

          </label></td>

        </tr>

        <tr>

          <td height="26">&nbsp;</td>

          <td height="26"><input type="submit" name="submitvalue" value="Update Me" /></td>

        </tr>

      </table>

    </form></td>

  </tr>

</table></fieldset>



<?php include("foot.php"); ?>